package org.ceteca.explica.core.common;

import java.io.Serializable;
import java.util.Date;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.ceteca.explica.core.InterfaceExplica;
import org.ceteca.explica.core.common.BaseVO;
import org.ceteca.explica.core.partners.AddressOT;

public class CurrencyOT extends BaseVO implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private long idCurrency;
	private String description;
	private double conversionRate;
	private Date lastUpdate;
	private String codeISO;
	private FlagOT flag;
	
	
	
	private Integer version=new Integer(0);

	public CurrencyOT() {
		super();
		description="";
		conversionRate=0.0;
		lastUpdate=new Date();
		codeISO="";
		flag=null;

	}

	
	


	public long getIdCurrency() {
		return idCurrency;
	}





	public void setIdCurrency(long idCurrency) {
		this.idCurrency = idCurrency;
	}





	public String getDescription() {
		return description;
	}





	public void setDescription(String description) {
		this.description = description;
	}





	public double getConversionRate() {
		return conversionRate;
	}





	public void setConversionRate(double conversionRate) {
		this.conversionRate = conversionRate;
	}





	public Date getLastUpdate() {
		return lastUpdate;
	}





	public void setLastUpdate(Date lastUpdate) {
		this.lastUpdate = lastUpdate;
	}





	public String getCodeISO() {
		return codeISO;
	}





	public void setCodeISO(String codeISO) {
		this.codeISO = codeISO;
	}







	public Integer getVersion() {
		return version;
	}









	@Override
	public boolean equals(Long id) {
		return id != null && this.idCurrency == id.longValue();
	}

	@Override
	public String getEntityId() {
		return InterfaceExplica.EXPLICA_ENTITY_CURRENCY_ID;

	}

	@Override
	public long getInternalId() {

		return idCurrency;
	}

	@Override
	public String getInternalValue() {

		return description;
	}





	public FlagOT getFlag() {
		return flag;
	}





	public void setFlag(FlagOT flag) {
		this.flag = flag;
	}





	public void setVersion(Integer version) {
		this.version = version;
	}
	
	
	   @Override
	    public int hashCode() {
	        final HashCodeBuilder hcb = new HashCodeBuilder();
	        hcb.append(getCodeISO());

	        return hcb.toHashCode();
	    }

	    
	    
	    @Override
	    public boolean equals(Object obj) {
	        boolean isEquals = false;
	        try {
	            final CurrencyOT other = (CurrencyOT)obj;
	            final EqualsBuilder eqb = new EqualsBuilder();
	            eqb.append(getCodeISO(), other.getCodeISO());
	            isEquals = eqb.isEquals();

	        } catch (Exception e) {
	            isEquals = false;
	        }

	        return isEquals;
	    }

}
